﻿namespace ChessKit.Logic
{
	public class BoardBuilder
	{
		internal byte[] Squares { get; private set; }

		public BoardBuilder()
		{
			Squares = new byte[128];
		}

		public int? EnPassantFile { get; set; }
		public int MoveNumber { get; set; }
		public int FiftyMoveClock { get; set; }
		public PieceColor SideOnMove { get; set; }
		public CastlingAvailability CastlingAvailability { get; set; }
		public Square? WhiteKingPosition { get; private set; }
		public Square? BlackKingPosition { get; private set; }
		public Piece this[Square index]
		{
			get { return (Piece)Squares[index]; }
			set
			{
				Squares[index] = (byte)value;
				switch (value)
				{
					case Piece.WhiteKing:
						WhiteKingPosition = index;
						break;
					case Piece.BlackKing:
						BlackKingPosition = index;
						break;
				}
			}
		}
		public ProtoBoard ToProtoBoard() { return new ProtoBoard(this); }
	}
}